import 'package:flutter/material.dart';
import 'LoginPage.dart';
import 'main.dart';

// ignore: must_be_immutable
class MinePage extends StatefulWidget {
  PageController controller;

  MinePage({this.controller});

  @override
  State<StatefulWidget> createState() {
    return MineState();
  }
  
}

class MineState extends State<MinePage> {
  List<String> data = ["消息", "收藏", "离线", "笔记"];
  static final int INDEX_ZERO = 0;
  static final int INDEX_ONE = 1;
  static final int INDEX_TWO = 2;
  static final int INDEX_THREE = 3;

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Color(0xff313131),
      child: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              Container(
                  width: 45,
                  height: 45,
                  margin: EdgeInsets.only(left: 8, top: 25),
                  child: IconButton(
                      icon: Image.asset("image/icon_close.png"),
                      onPressed: () {
                        print("返回首页");
                        widget.controller.animateToPage(HomePage.PAGE_MAIN, duration: Duration(milliseconds: 1500), curve: ElasticOutCurve(2));
                      }
                  )
              ),
              Expanded(
                child: Text(""),
              ),
              Container(
                  width: 45,
                  height: 45,
                  margin: EdgeInsets.only(right: 8, top: 25),
                  child: IconButton(
                    icon: Image.asset("image/icon_setting.png"),
                    onPressed: () {

                    },
                  )
              )
            ],
          ),
          FlatButton(
              onPressed: () {
                Navigator.push(context, MaterialPageRoute(builder: (context) => LoginPage()));
              },
              child: Container(
                width: 150,
                height: 150,
                padding: EdgeInsets.only(top: 20,bottom: 25),
                child: Image.asset("image/img_user.png"),
              ),
          ),
          Text(
              "登录",
            style: TextStyle(
              color: Colors.white
            ),
          ),
          Padding(
            padding: EdgeInsets.only(top: 20),
          ),
          createWidget(data[INDEX_ZERO], index: INDEX_ZERO),
          createWidget(data[INDEX_ONE], index: INDEX_ONE),
          createWidget(data[INDEX_TWO], index: INDEX_TWO),
          createWidget(data[INDEX_THREE], index: INDEX_THREE),
        ],
      )
    );
  }

  Widget createWidget(String title, {int index}) {
    int i = index;
    return GestureDetector(
      child: Padding(
          child: Text(title,
              style: TextStyle(
                  color: Colors.white,
                  fontSize: 32
              )
          ),
          padding: EdgeInsets.only(top: 25)
      ),
      onTap: () {
        if(i == INDEX_ZERO) {

        } else if(i == INDEX_ZERO) {

        } else if(i == INDEX_ZERO) {

        } else {

        }
      },
    );
  }
}